using System;
using System.BusinessObjects.Transactions;
using Blazing.BusinessObjects.Cms;
using NHibernate;
using NHibernate.Criterion;

namespace Blazing.BusinessObjects.Queries
{
    public class QrySearchPages
    {
        public static ICriteria Query(int siteId, Nullable<int> parentPageId)
        {
            ICriteria qry = UnitOfWork.CurrentSession.CreateCriteria(typeof(Contentpage));
            qry.Add(Expression.Eq("Site", siteId));
            if (parentPageId != null)
                qry.Add(Expression.Eq("ParentPage", parentPageId.Value));
            qry.AddOrder(Order.Asc("Name"));

            qry.SetCacheable(true);
            return qry;
        }
    }
}
